#ifndef JOB_H
#define JOB_H

namespace bimar_scheduler_lib
{

typedef std::list<CTask *> TaskList;
typedef TaskList::iterator TaskListIt;

class CJobExecutor;			/* composite pattern. task execution */
class CJob : public CTask	/* composite pattern */
{
  friend class CJobScheduler;

public:
  CJob(gboolean taskOwner = TRUE);
  virtual ~CJob();

  gboolean PushBack(CTask *task);
  gboolean Remove(CTask *task);
  gboolean Delete(CTask *task);
  gboolean Delete();
  gboolean Clear();
  gboolean IsEmpty();
  glong GetSize();
  CTask * PopFront();
  CTask * Get(glong index);
  void SetJobStatus(EStatus status) { m_jobStatus = status; }
  EStatus GetJobStatus() { return m_jobStatus; }

  /* CTask overrides */
  gboolean Run();
  gboolean Stop();
  gboolean Pause();
  gboolean Resume();
  gboolean Abort();

protected:
  gboolean m_taskOwner;						//!< is task owner
  CGCriticalSectionWrapper m_taskListCS;	//!< thread safe access to task list
  TaskList m_taskList;						//!< task list
  CGCriticalSectionWrapper m_executorCS;
  CJobExecutor *m_executor;					//!< composite pattern
  EStatus m_jobStatus;						//!< status as job
};

}; /* namespace */

#endif // JOB_H
